<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .container{
            display: flex;
            justify-content: space-around;
        }
        .item{
            width: 200px;
            height: 100px;
            border: 1px solid red;
            margin: 5px;
        }
    </style>
</head>
<body>
<h2 class="page-header">点击切换颜色</h2>
<div class="container">
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
</div>
<script>
    let items=document.querySelectorAll('.item')
    for (let i = 0; i < items.length; i++) {
        items[i].onclick=function () {
            // this.style.background='pink'
            items[i].style.background='pink'
        }
    }
    console.log(window.i)
</script>
</body>
</html>
